//package com.samphanie.security.rest;
//
//import com.samphanie.common.enums.CodeType;
//import com.samphanie.common.utils.ApiResponse;
//import com.samphanie.security.security.properties.AuthConstants;
//import com.samphanie.security.validation.ValidateCodeProcessorHolder;
//import com.samphanie.security.domain.Captcha;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import lombok.RequiredArgsConstructor;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.context.request.ServletWebRequest;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * @author ZSY
// * @email 1451691457@qq.com
// */
//@Api(tags = "验证码模块接口")
//@RestController
//@RequestMapping(AuthConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX)
//@RequiredArgsConstructor
//public class ValidateCodeController {
//
//    private final ValidateCodeProcessorHolder validateCodeProcessorHolder;
//    private final HttpServletRequest request;
//    private final HttpServletResponse response;
//
//    /**
//     * 创建验证码，根据验证码类型不同，调用不同的 {@link Captcha}接口实现
//     */
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "type", value = "验证码类型：sms | image", paramType = "path", dataTypeClass = String.class, required = true),
//            @ApiImplicitParam(name = "deviceId", value = "唯一标识：客户端ID+用户设备码", paramType = "header", dataTypeClass = String.class, required = true)
//    })
//    @ApiOperation("发送验证码")
//    @GetMapping("/{type}")
//    public void createCode(@PathVariable String type) {
//        validateCodeProcessorHolder.findValidateCodeProcessor(type)
//                .render(new ServletWebRequest(request, response));
//    }
//
//    /**
//     * 创建图片验证码
//     */
//    @ApiOperation("发送图片验证码")
//    @ApiImplicitParam(name = "deviceId", value = "唯一标识：客户端ID+用户设备码", paramType = "header", dataTypeClass = String.class, required = true)
//    @GetMapping("/sendImageCode")
//    public void sendImageCode() {
//        String type = CodeType.IMAGE.getName();
//        validateCodeProcessorHolder.findValidateCodeProcessor(type)
//                .render(new ServletWebRequest(request, response));
//    }
//
//    @ApiOperation("发送短信验证码")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "mobile", value = "手机号", dataTypeClass = String.class, required = true),
//            @ApiImplicitParam(name = "deviceId", value = "唯一标识：客户端ID+用户设备码", paramType = "header", dataTypeClass = String.class, required = true)
//    })
//    @GetMapping("/sendSmsCode")
//    public ApiResponse<?> sendSmsCode(@RequestParam(value = "mobile") String mobile) {
//
//        String type = CodeType.SMS.getName();
//        request.setAttribute("mobile", mobile);
//        validateCodeProcessorHolder.findValidateCodeProcessor(type)
//                .render(new ServletWebRequest(request, response));
//
//        return ApiResponse.success("发送成功");
//    }
//
//}
